package com.dgshanger.sanhxiaofeisc.mvp.presenter

import com.dgshanger.sanhxiaofeisc.entity.PayResultEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.PayResultContract
import com.dgshanger.sanhxiaofeisc.mvp.model.PayResultModel
import com.xx.baseuilibrary.mvp.BaseMvpPresenter
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/20.
 */
class PayResultPresenter : BaseMvpPresenter<PayResultContract.Model, PayResultContract.View>(), PayResultContract.Presenter {

    override fun loadData(isRefresh: Boolean, record_sn: String?) {
        getModel().loadData(record_sn,object : XxBaseHttpObserver<PayResultEntity>(){
            override fun onCompleted(msg: String?, entity: PayResultEntity?) {
                getView()?.setData(entity)
            }

            override fun onError(error: String?) {
                getView()?.showToast(error)
                getView()?.showError(Throwable(error),isRefresh)
            }

            override fun onStart() {

            }

            override fun onFinish() {
                getView()?.dismissLoadingDialog()
            }

        })
    }

    override fun createModel(): PayResultContract.Model = PayResultModel()
}